package biz.innovasoft.nodb.transaction;

import java.util.Date;

import org.prevayler.Prevayler;
import org.prevayler.Query;

import biz.innovasoft.nodb.impl.FindHelper;
import biz.innovasoft.nodb.impl.GenericRepository;
import biz.innovasoft.nodb.query.QueryCriteria;
import biz.innovasoft.nodb.query.Result;

public class SelectByCriteriaQuery implements Query {

	private Prevayler prevayler;
	private QueryCriteria criteria;
	
	public SelectByCriteriaQuery (Prevayler prevayler, QueryCriteria criteria) {
		this.prevayler = prevayler;
		this.criteria = criteria;
	}
	
	
	@Override
	public Object query(Object prevalentSystem, Date time) throws Exception {
		GenericRepository repository = (GenericRepository)prevalentSystem;
		FindHelper finder = new FindHelper (prevayler, repository, criteria);
		Result result = finder.find();
		return result;
	}

}
